package net.wanho.controller;

import lombok.RequiredArgsConstructor;
import net.wanho.po.Dept;
import net.wanho.service.DeptService;
import net.wanho.vo.AjaxResult;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 部门表 前端控制器
 * </p>
 *
 * @author 汤小洋
 * @since 2025-09-22
 */
@RestController
@RequestMapping("/dept")
@RequiredArgsConstructor
public class DeptController {

    private final DeptService deptService;

    @GetMapping
    public AjaxResult findAll(){
        return AjaxResult.success(deptService.list());
    }

    @PostMapping("/add")
    public AjaxResult add(@RequestBody Dept dept){
        return AjaxResult.success(deptService.save(dept));
    }

}
